package com.jic.market.common.enums;

import java.util.EnumSet;

/**
 * @author : xuyongliang
 * @date : 2020/3/1 8:44 AM
 * @description: ${description}
 * @modified By:
 * @version: V1.0
 */
public enum LimitTypeEnum {

    // 限制类型：0 不限，1 促销，2 商家，3 商品，4 优惠码 ,5 产品
    UNLIMITED(0, "不限"),
    PROMOTION(1, "促销"),
    MERCHANT(2, "商家"),
    GOODS(3, "商品"),
    COUPON_CODE(4, "优惠码"),
    PRODUCT(5, "产品");

    private Integer code;

    private String value;

    LimitTypeEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static LimitTypeEnum getEnumByCode(Integer code){
        EnumSet<LimitTypeEnum> elements = EnumSet.allOf(LimitTypeEnum.class);
        for(LimitTypeEnum enumType : elements){
            if(enumType.getCode().equals(code)){
                return enumType;
            }
        }
        return null;
    }

    public static String getValue(Integer code) {
        return getEnumByCode(code).getValue();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
